package com.hy.mydesktop.shared.util.log;

import java.util.logging.Level;
import java.util.logging.Logger;

import com.allen_sauer.gwt.log.client.Log;
import com.allen_sauer.gwt.log.client.LogUtil;
import com.extjs.gxt.ui.client.event.EventType;
import com.google.gwt.user.client.Window;

public class GwtLogHelper {

	public static void printEventResponseByDebug(EventType eventType) {
         if (!Log.isLoggingEnabled()) {
              Window.alert("Logging is disabled. No log messages will appears.");
            }

			Log.debug("当前类响应 "+eventType+" 事件");

      }
	
	public static String printEventResponseByDebug(String className,EventType eventType) {
        

			return className+"类:响应 "+eventType+" 事件";

     }
	
	public static String printEventResponseByDebug(String className,String eventName) {
        

		return className+"类:响应 "+eventName+" 事件";

	}
	
	public static String printEventResponseByDebug(Class className,String eventName) {
        
	return className+"类:响应 "+eventName+" 事件";


	}

	private static void printDebug(String className,String message,Throwable throwable) {
		StackTraceElement[] stackTraceElements= throwable.getStackTrace();
		/*System.out.println("size :"+stackTraceElements.length);
		for (int s = 0; s < stackTraceElements.length; s++) {
		      System.out.println(s + " " + stackTraceElements[s].getClassName()
		          + stackTraceElements[s].getClassName() + stackTraceElements[s].getLineNumber());
		    }
		 System.err.println(str);*/
		String str = "" + "(" + stackTraceElements[1].getFileName()+":" + stackTraceElements[1].getLineNumber()+")";
		Logger logger = Logger.getLogger(className);
		  StackTraceElement ste = LogUtil.getCallingStackTraceElement(throwable);
	
		  
		 logger.log(Level.FINE,str+" " + message);
		
	}
	
	public static void printDebug(String className,String message) {
		 printDebug(className,message, new Throwable());
	}

}
